package cn.com.winning.ecare.common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import yxt.push.org.androidpn.client.NotificationDetailsActivity;
import android.content.Context;
import android.content.Intent;
import cn.com.winning.ecare.activity.ClinicPathOne;
import cn.com.winning.ecare.activity.CostSelect;
import cn.com.winning.ecare.activity.Costeveryday;
import cn.com.winning.ecare.activity.GhOne;
import cn.com.winning.ecare.activity.Health1;
import cn.com.winning.ecare.activity.HospitalOne;
import cn.com.winning.ecare.activity.MedicalRecordActivity;
import cn.com.winning.ecare.activity.Process;
import cn.com.winning.ecare.activity.R;
import cn.com.winning.ecare.activity.ReportActivity;
import cn.com.winning.ecare.activity.SSSelect;
import cn.com.winning.ecare.activity.Shop;
import cn.com.winning.ecare.activity.Suggestion;
import cn.com.winning.ecare.activity.Yndh;
import cn.com.winning.ecare.utils.Utils;

public class Grideviewmenu {
	// 获取GrideView数据
		public ArrayList<HashMap<String, Object>> initItem(MyApplication myApplication) {
			List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
			JSONArray items;
			try {
				items = new JSONArray(myApplication.getGnlb());
				for (int j = 0; j < items.length(); j++) {
					JSONObject jobj = items.getJSONObject(j);
					list.add(Utils.getMap(jobj.toString()));
				}
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			String bm = "";// 别名，功能名称不同医院会取不同值，所以这里用别名判断
			String gnmc = "";// 功能名称
			ArrayList<HashMap<String, Object>> lstImageItem = new ArrayList<HashMap<String, Object>>();
			HashMap<String, Object> map = new HashMap<String, Object>();
			for (int i = 0; i < list.size(); i++) {

				gnmc = list.get(i).get("gnmc").toString();
				bm = list.get(i).get("bm").toString();
				// if (bm.equals("")) {
				map = new HashMap<String, Object>();
				if ("病历查询".equals(gnmc)) {
					map.put("ItemImage", R.drawable.blcx);
				} else if ("膳食查询".equals(gnmc)) {
					map.put("ItemImage", R.drawable.ssqk_select);
				} else if ("一日清单".equals(gnmc)) {
					map.put("ItemImage", R.drawable.ylfy_select);
				} else if ("检查检验".equals(gnmc)) {
					map.put("ItemImage", R.drawable.jybg_select);
				} else if ("临床路径".equals(gnmc)) {
					map.put("ItemImage", R.drawable.lclj_select);
				} else if ("疾病百科".equals(gnmc)) {
					map.put("ItemImage", R.drawable.jkzs_select);
				} else if ("满意度".equals(gnmc)) {
					map.put("ItemImage", R.drawable.myddc_select);
				} else if ("意见建议".equals(gnmc)) {
					map.put("ItemImage", R.drawable.yjx_select);
				} else if ("医院信息".equals(gnmc)) {
					map.put("ItemImage", R.drawable.yyxx_select);
				} else if ("自选超市".equals(gnmc)) {
					map.put("ItemImage", R.drawable.zxcs_select);
				} else if ("预约挂号".equals(gnmc)) {
					map.put("ItemImage", R.drawable.yygh_select);
				}else if ("院内导航".equals(gnmc)) {
					map.put("ItemImage", R.drawable.zxcs_select);
				}else if ("就诊助手".equals(gnmc)) {
					map.put("ItemImage", R.drawable.zxcs_select);
				}else if ("医疗费用".equals(gnmc)) {
					map.put("ItemImage", R.drawable.ylfy_select);
				}

				map.put("ItemText", gnmc);// 按对应功能名称显示ItemText
				lstImageItem.add(map);
				// }

			}
			return lstImageItem;
		}
		
		public Intent findActivity(Intent intent,HashMap<String, Object> Item,Context con){
			if (Item.get("ItemText").equals("病历查询")) {
				intent = new Intent(con, MedicalRecordActivity.class);
			} else if (Item.get("ItemText").equals("检查检验")) {
				intent = new Intent(con, ReportActivity.class);
			} else if (Item.get("ItemText").equals("膳食查询")) {
				intent = new Intent(con, SSSelect.class);
			} else if (Item.get("ItemText").equals("一日清单")) {
				intent = new Intent(con, Costeveryday.class);
			} else if (Item.get("ItemText").equals("临床路径")) {
				intent = new Intent(con, ClinicPathOne.class);
			} else if (Item.get("ItemText").equals("满意度")) {
				intent = new Intent(con, Process.class);
			} else if (Item.get("ItemText").equals("疾病百科")) {
				intent = new Intent(con, Health1.class);
			} else if (Item.get("ItemText").equals("意见建议")) {
				intent = new Intent(con, Suggestion.class);
			} else if (Item.get("ItemText").equals("医院信息")) {
				intent = new Intent(con, HospitalOne.class);
			} else if (Item.get("ItemText").equals("自选超市")) {
				intent = new Intent(con, Shop.class);
			} else if (Item.get("ItemText").equals("预约挂号")) {
				intent = new Intent(con, GhOne.class);
			}else if (Item.get("ItemText").equals("院内导航")) {
				intent = new Intent(con, Yndh.class);
			}else if (Item.get("ItemText").equals("就诊助手")) {
				intent = new Intent(con, NotificationDetailsActivity.class);
			} else if (Item.get("ItemText").equals("医疗费用")) {
				intent = new Intent(con, CostSelect.class);
			}
			return intent;
			
		}
}
